home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / bas_int1.zip / ISFILE@.BAS < prev    next >
BASIC Source File  |  1991-03-12  |  963b  |  31 lines

  1. '==================================================================
  2. 'Another Filexist Routine
  3. 'Source: FideNet Quick Basic Forum
  4. '   Date : 11-Mar-91
  5. '   From : Bob Perkins
  6. '==================================================================
  7. 'main()         'Sample Main program calling Sub Filexist()
  8.  '$INCLUDE: 'QB.BI'
  9.  DECLARE SUB Filexist (Filename$, notexist%)
  10.  DIM SHARED Regs AS RegType
  11.  '
  12.  'You will need to start QB with "QB /L" to load the interrupt lib.
  13.  '
  14.  Filexist "abc.txt", notexist%
  15.  IF notexist% THEN PRINT "File does not exist." ELSE PRINT "File exists."
  16.  END
  17.  '
  18.  SUB Filexist (Filename$, notexist%)
  19.   'returns 0 in notexist% if file exists, non-zero if it does not...
  20.   Testname$ = Filename$ + CHR$(0)
  21.   Regs.AX = &H4E00
  22.   Regs.cx = &H0
  23.   Regs.dx = SADD(Testname$)
  24.   CALL interrupt(&H21, Regs, Regs)
  25.   notexist% = 0
  26.      IF (&H1 AND Regs.flags) <> 0 THEN
  27.         notexist% = Regs.AX AND &HF
  28.      END IF
  29.   END SUB
  30.  
  31.